let $cuser := (session:set-current-user("admin",""))
let $nsprefix := "cv"
let $schema := doc(concat("/db/xrai/",$nsprefix,"/schemas/",$nsprefix,".xsd"))
let $t1 := doc(concat("db/xrai/common/xslt/buildMetastructure.xsl",""))
let $metabase := transform:transform($schema,$t1,<params/>)
let $update := (xmldb:store(concat("/db/xrai/",$nsprefix,"/overlays/"),concat($nsprefix,".meta.xml"),$metabase))
let $overlay  := doc(concat("/db/xrai/",$nsprefix,"/overlays/",$nsprefix,".meta.delta.xml",""))
let $t2 := doc(concat("/db/xrai/common/xslt/extendMetastructure.xsl",""))
let $metafull := transform:transform($overlay,$t2,<params/>)
let $update := (xmldb:store(concat("/db/xrai/",$nsprefix,"/overlays/"),concat($nsprefix,".meta.final.xml"),$metafull))
let $t3 := doc(concat("/db/xrai/common/xslt/generateEditor.xsl",""))
let $final := transform:transform($metafull,$t3,<params/>)
let $update := (xmldb:store(concat("/db/xrai/",$nsprefix,"/views/"),"editor.xml",$final))
return
<html xmlns="http://www.w3.org/1999/xhtml">
    <body>
         <a href="{concat("/exist/rest//db/xrai/common/xq/editor.xq?topic=",$nsprefix,';id=new')}">Editor with New Entry</a>
    </body>
</html>



